# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        Young  
# Name:         hmwk01
# Description:  异常捕捉
# Author:       asus
# Date:         2019/3/20
#-------------------------------------------------------------------------------


# 1580733xxxx
# 最后四位从1-9999中随机生成，生成数小于50抛出异常
# 未满四位补零
# 生成的号码已字符串形式保存在列表

class StartMobileException(Exception):
    # 定义异常类
    pass


class Mobile:
    def __init__(self):
        self.phone = ''
        self.list = []

    def start(self):
        # 定义抛出异常的方法
        import random
        a = random.randint(1,99)
        if a < 50:
            raise StartMobileException('****小于50****')
        else:
            self.phone = '1580733{:0>4}'.format(a)
            self.list.append(self.phone)
            return self.list

if __name__ == '__main__':
    while True:
        try:
            tel = Mobile()
        except StartMobileException:
            pass
        print(tel.start())














